package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.response.MealDetailInfo;
import com.pj.wisdomlogistics.mvp.contract.MealDetailContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.MealDetailModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;

import java.io.File;


public class MealDetailPresenter extends ActivityPresenter<MealDetailModel,MealDetailContract.View> implements MealDetailContract.Presenter{
    public static final String TAG = "MealDetailPresenter";


    @Override
    public void findDiningApplyDetail(int diningApplyID) {
        addSubscription(getModel().findDiningApplyDetail(diningApplyID), new FilterSubscriber<MealDetailInfo>() {
            @Override
            public void onNext(MealDetailInfo mMealDetailInfo) {
                getView().onSuccess(mMealDetailInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }


        });
    }

    @Override
    public void diningApplySign(String userID, int diningApplyID, File sign, int state , String comment) {
        addSubscription(getModel().diningApplySign(userID, diningApplyID, sign, state, comment), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onSignSuccess();
            }
        });
    }

    @Override
    public void diningApplySign2(String userID, int diningApplyID, File sign, int state , String comment) {
        addSubscription(getModel().diningApplySign2(userID, diningApplyID, sign, state, comment), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onSignSuccess();
            }
        });
    }

    @Override
    public void diningApplyReview(String userID, int diningApplyID, String state, String comment) {
        addSubscription(getModel().diningApplyReview(userID, diningApplyID, state, comment), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onReviewSuccess();
            }
        });
    }

    @Override
    public void diningApplyFinish(String userID, int diningApplyID, String state, String comment , String room) {
        addSubscription(getModel().diningApplyFinish(userID, diningApplyID, state, comment , room), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onFinishSuccess();
            }
        });
    }

    @Override
    public void cancelDiningApply(int diningApplyID) {
        addSubscription(getModel().cancelDiningApply(diningApplyID), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onUndoSuccess();
            }
        });
    }
}
